#ifndef _OBJECT_H
#define _OBJECT_H

#include "ParticleSystem.h"
#include "Particle.h"
#include "Triangle.h"

#include <cstdlib>
#include <set>

using namespace std;

class ParticleSystem; // forward declaration
class CollisionSystem; // forward declaration

/* To keep collision management simple, an object will be for now a simple
 * geometric shape. Otherwise we would have to implement a two level octree
 * hierarchy: one octree for the whole scene that holds objects and one octree for each object that holds very basic primitives (triangles?).
 */
class Object {
public:
	// The particle system in which this object is simulated
	ParticleSystem* particleSystem;
	// The collision system responsible for handling collisions for this object
	CollisionSystem* collisionSystem;
	// The mass particles that make up this object
	set<Particle*> particle;
	// The constraints that keep this object in one piece
	set<Constraint*> constraint;
	// The triangle mesh that defines this object's collision surface
	set<Triangle*> triangle;
public:
	Object(ParticleSystem* _particleSystem = NULL);
	virtual void verlet();
	virtual void satisfyConstraints();
	virtual void accumulateForces() {};
	void setAcc(const Vector3& acc);
	void setDamping(double damping);
	//virtual bool collide(Object &o) = 0;
	virtual const set<Particle*>& getEnvelope();
	virtual ~Object();
private:
	void updateCollisionSystem();
};

#endif /* _OBJECT_H */
